package 观察者模式;

public class Goods extends Subject{
    private int price;

    public Goods(int price) {
        this.price = price;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        int num=price-this.price;//变化量
        this.price = price;
        if (num!=0)this.notifyAllObservers(num);
    }
}
